#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
typedef int datatype;
typedef struct seq_stack
{
	datatype* a;
	int top;
	int size;
}ST;

ST* Stack_Init(int s)
{
	ST* ps = (ST*)malloc(sizeof(ST));
	if (ps == NULL)
	{
		printf("malloc fail\n");
		return NULL;
	}
	ps->a = (datatype*)malloc(sizeof(datatype) * s);
	if (ps->a == NULL)
	{
		printf("malloc fail");
		free(ps);
		return NULL;
	}
	ps->size = s;
	ps->top = -1;
	return ps;
}
bool is_full(ST* ps)
{
	if (ps->top == ps->size - 1)
		return true;
	else
		return false;
}
bool is_empty(ST* ps)
{
	if (ps->top == -1)
		return true;
	else
		return false;
}
bool Stack_Push(ST* ps, datatype data)
{
	if (is_full(ps))
		return false;
	ps->top++;
	ps->a[ps->top] = data;
	return true;
}
bool Stack_Pop(ST* ps, datatype* x)
{
	if (is_empty(ps))
		return false;
	*x = ps->a[ps->top];
	ps->top--;
	return true;
}

void dec_to_oct(int n)
{
	if (n < 0)
	{
		printf("number is invaild");
		return;
	}
	ST* phead = Stack_Init(10);
	while (n != 0)
	{
		Stack_Push(phead, n % 8);
		n = n / 8;
	}
	int data;
	while (!is_empty(phead))
	{
		Stack_Pop(phead, &data);
		printf("%d", data);
	}
	printf("\n");
}
int main()
{
	int a = 0;
	scanf("%d", &a);
	dec_to_oct(a);

	return 0;
}